package com.test.mywebapp.client;

import com.google.gwt.user.client.ui.Image;

public class Board {

	final public static String Cross = "X";
	final public static String Zero = "O";
	
	private String player = "";
	
	private BoardCell[] cells = new BoardCell[9];
	
	Board(){
		for(int i = 0; i < 9; i++){
			this.cells[i] = new BoardCell(this);
		}
		this.reset();
	}
	
	public Image getImage(int i){
		return this.cells[i].getImage();
	}
	
	public String player(){
		return this.player;
	}
	
	public void occupy(){
		if (this.player == Board.Cross){
			this.player = Board.Zero;
		}
		else{
			this.player = Board.Cross;
		}
	}
	
	public void reset(){
		for(int i = 0; i < 9; i++){
			this.cells[i].reset();
		}
		this.player = Board.Cross;
	}
}